<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class House extends Model
{
    use HasFactory;
    protected $guarded=[];
    protected $table="fang_publish";
    //查看所有的二手房
    static function lookHouse(int $page){
        return self::where('is_del','0')->paginate(5)->toArray();
    }
    static function allHouse(){
        return self::where('is_del','0')->get()->toArray();
    }
    //查找房
    static function findHouse(array $where){
        return self::where($where)->where('is_del','0')->get()->toArray();
    }
    //添加房
    static function addHouse(array $params){
        return   self::create($params)->toArray();
    }
    //修改房
    static function updateBroker(int $id,array $params){
        return self::where('id',$id)->where('is_del','0')->update($params);
    }
    //删除房
    static function deleteBroker(int $id){
        return self::where('id',$id)
            ->where('is_del','0')
            ->update(['is_del'=>'1']);
    }
}
